import java.util.Scanner;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/5/14
 * \* Time: 15:45
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */

class Rational{
    private long numerator;//分子
    private long denominator;//分母
    private long integer;  //整数部分
    private boolean negetive =false; //附属
    private boolean isZeor = false ; //分母为0
    private long totalNumerator; //参与运算的分子：整数+原来的分子

    public static long paraseNumerator(String s){
        //只需从字符串中将分子截取出来
        return Long.parseLong(s.substring(0,s.indexOf('/')));
    }
    public static long paraseDenominator(String s){
        //截取分母
        return Long.parseLong(s.substring('/')+1,s.length());
    }
    public Rational(long n ,long d){
        //在输入的时候，分母永远不可能为0，但经过计算之后，分母可能为0
        if(0 == d){
            isZeor = true;
            return;
        }
        //如果分子《0，表示为附属
        if(n < 0){
            negetive = !negetive;
        }
        //在输入的时候，分母永远不可能小于0，但经过计算之后，分母也可能会小于0
        if(d < 0){
            negetive = !negetive;
        }
        //如果输入的是假分数，需要将其调整为真分数，比如 5/3 ==> 1 2/3
        integer = n/d;
        numerator = n-integer*d;
        denominator = Math.abs(d );

        //如果分数不是最简的形式，需要将其约分为最简的形式，比如10/15
        //在分子和分母的基础之上分别除以分子和分母的最大公约数
        if(numerator > 1 || numerator < -1){
            long gcd = caleGCD(Math.abs(numerator),denominator);
            if(gcd > 0){
                numerator /= gcd;
                denominator /= gcd;
            }
        }
        totalNumerator = numerator + integer*denominator;
    }
    //求最大公约数，用辗转相除法
    private long caleGCD(long a,long b){
        if(0 == b){
            return a;
        }
        return caleGCD(b,a%b);
    }

    public Rational Add(Rational r){
        long n = totalNumerator* r.denominator+ denominator*r.totalNumerator;
        long d = denominator * denominator;
        return new Rational(n,d);
    }
    public Rational Sub(Rational r){
        long n = totalNumerator* r.denominator+ denominator*r.totalNumerator;
        long d = denominator * r.denominator;
        return new Rational(n,d);
    }
    public Rational Mul(Rational r){
        long n = totalNumerator * r.totalNumerator;
        long d = denominator * r.denominator;
        return new Rational(n,d);
    }
    public Rational Div(Rational r){
        long n = totalNumerator * r.totalNumerator;
        long d = denominator * r.numerator;
        return new Rational(n,d);
    }

    public String toString(){
        StringBuffer s = new StringBuffer();
        //分母为0，则不进行输出了
        if(isZeor){
            s.append("Inf");
            return new String(s);
        }
        if(negetive){
            s.append('(');
        }
        //输出RATIONAL:整数部分 + 分数部分
        //整数部分
        if(integer != 0){
            s.append(integer);
            //整数部分和分数部分需要使用空格隔开
            if(numerator != 0){
                s.append(' ');
            }
        }

        //分数部分：可能存在，也可能不存在
        if(0 != numerator){
            s.append(Math.abs(numerator));
            s.append('/');
            s.append(denominator);
        }
        if(negetive){
            s.append('(');
        }
        return new String(s);
    }

}


public class day36 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            String s = sc.next();
            Rational r1 = new Rational (Rational.paraseNumerator(s), Rational.paraseDenominator(s));

            s = sc.next();
            Rational r2 = new Rational (Rational.paraseNumerator(s), Rational.paraseDenominator(s));
            System.out.println(r1 + " +"+ r2 + "=" + r1.Add(r2));
            System.out.println(r1 + " -"+ r2 + "=" + r1.Sub(r2));
            System.out.println(r1 + " *" +r2 + "=" + r1.Mul(r2));
            System.out.println(r1 + " /"+ r2 + "=" + r1.Div(r2));
        }
    }
}
